#region " LICENSE "
// DRILL - Dependency Resolution Interface Layer Library
// Copyright (c) 2008-2012 Wade A. Reynolds. All rights reserved.
// http://drill.codeplex.com/
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#endregion
using System;
using System.Collections;
using System.Collections.Generic;

namespace Drill
{
    /// <summary>
    /// Interface implemented by classes used to resolve dependency types, 
	/// locate services or obtain object instances from containers, locators, 
	/// factories, contexts or other sources.
    /// </summary>
    /// <remarks>
    /// Implementers can implement one of two public constructor signatures:
	/// public MyDependencyResolver() or public MyDependencyResolver(IDependencyResolverInitContext context).
	/// The constructor signature with the constructor context argument is the recommended constructor signature.
    /// </remarks>
    public interface IDependencyResolver : IDisposable
    {
        /// <summary>
        /// Gets an instance of the type specified by <paramref name="targetType"/>.
        /// </summary>
        /// <param name="targetType">The type of object to be retrieved.</param>
        /// <returns>An instance of the requested type.</returns>
        object GetInstance(Type targetType);

        /// <summary>
        /// Gets a named instance of the type specified by <paramref name="targetType"/>.
        /// </summary>
        /// <param name="targetType">The type of object to be retrieved.</param>
        /// <param name="name">The name of the specific object instance.</param>
        /// <returns>An instance of the requested named type.</returns>
        object GetInstance(Type targetType, string name);

        /// <summary>
        /// Get all instances of the type specified by <paramref name="targetType"/>.
        /// </summary>
        /// <param name="targetType">The type of object to be retrieved.</param>
        /// <returns>
        /// An <see cref="IEnumerable"/> instance representing all 
        /// available instances of the requested type.
        /// </returns>
        IEnumerable GetAllInstances(Type targetType);

        /// <summary>
        /// Gets an instance of the type specified by <typeparamref name="TTargetType"/>.
        /// </summary>
        /// <typeparam name="TTargetType">The type of object to be retrieved.</typeparam>
        /// <returns>An instance of the requested type.</returns>
        TTargetType GetInstance<TTargetType>();

        /// <summary>
        /// Gets a named instance of the type specified by <typeparamref name="TTargetType"/>.
        /// </summary>
        /// <typeparam name="TTargetType">The type of object to be retrieved.</typeparam>
        /// <param name="name">Name the object was registered with.</param>
        /// <returns>An instance of the requested named type.</returns>
        TTargetType GetInstance<TTargetType>(string name);

        /// <summary>
        /// Get all instances of the type specified by <typeparamref name="TTargetType"/>.
        /// </summary>
        /// <typeparam name="TTargetType">The type of object to be retrieved.</typeparam>
        /// <returns>
        /// An <see cref="IEnumerable{TTargetType}"/> instance representing all 
        /// available instances of the requested type.
        /// </returns>
        IEnumerable<TTargetType> GetAllInstances<TTargetType>();
    }
}